package org.example.controller;

import org.example.service.api.DepositServiceApi;
import org.example.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 充值相关操作
 *
 */
@ResponseBody
@Controller
@CrossOrigin
public class DepositTbController {

    //服务层
    @Autowired
    DepositServiceApi depositService;

    /**
     * 充值记录
     * @param depositId 充值记录id查询
     * @return
     */
    @GetMapping("/queryDepositById")
    public JSONResult adminQueryDepositById(Integer depositId){
        JSONResult jsonResult= depositService.adminQueryDepositById(depositId);
        return jsonResult;
    }

    /**
     * 通过宿舍id删除充值记录
     * @param dormitoryId
     * @return
     */

    @GetMapping("/deleteDepositByDormitoryId")
    public JSONResult adminDeleteDepositByDormitoryId(Integer dormitoryId){
        JSONResult jsonResult =depositService.adminDeleteDepositByDormitoryId(dormitoryId);
        return jsonResult;
    }

    /**
     * 通过充值记录id删除
     * @param depositId
     * @return
     */
    @GetMapping("/deleteDepositById")
    public JSONResult adminDeleteDepositById(Integer depositId){
        JSONResult jsonResult=depositService.adminDeleteDepositById(depositId);
        return jsonResult;
    }

    /**
     * 通过用户名删除充值记录id
     * @param userId
     * @return
     */
    @GetMapping("/deleteDepositByUserId")
    public JSONResult adminDeleteDepositByUserId(Integer userId){
        JSONResult jsonResult=depositService.adminDeleteDepositByUserId(userId);
        return jsonResult;
    }

    /**
     * 添加充值记录
     * @param userId
     * @param dormitoryId
     * @param userFee
     * @return
     */

    @GetMapping("/addDepositMonkey")
    public JSONResult adminAddDepositMonkey(Integer userId,Integer dormitoryId,Integer userFee){
        JSONResult jsonResult=depositService.adminAddDepositMonkey(userId,dormitoryId,userFee);
        return jsonResult;
    }

    @GetMapping("/alterDepositInfo")
    public JSONResult adminAlterDepositInfo(Integer dormitoryId,Integer userId,Integer userFee ,Integer depositId){
        JSONResult jsonResult=depositService.adminAlterDepositInfo(dormitoryId,userId,userFee,depositId);
        return jsonResult;

    }

}
